﻿
@{
    ViewBag.Title = "DiaryManager";
    Layout = "~/Views/Shared/_LayoutBase.cshtml";
    @model RTW.OA.Areas.Personal.Models.DiaryCollection
}
@section styles{
    <style type="text/css">
        .content-ellipsis {
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 3;
        }
    </style>
}

<div class="container">

    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">全部日志</a></li>
        <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">我的日志</a></li>
        <li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">其他人日志</a></li>

        <li class="pull-right">
            <div class="pull-right">
                <a class="btn btn-sm btn-success radius" onclick="parent.createTab('0801','新建日志','@Url.Action("Edit", "Diary", new { area = "Personal" })')"><i class="iconfont icon-tianjia"></i>&nbsp;写日志</a>
                <a class="btn btn-sm btn-info radius" onclick="parent.createTab('0804','日志查询','@Url.Action("Search","Diary",new { area="Personal"})')"><i class="iconfont icon-tianjia"></i>&nbsp;日志查询</a>
            </div>
        </li>
    </ul>

    <!-- Tab panes -->
    <div class="tab-content ">
        <div role="tabpanel" class="tab-pane active" id="home">
            <div class="widget-box container">
                <div style="margin-bottom:10px;">
                </div>
                <div class="widget-body ">
                    <div class="widget-main padding-8">
                        @foreach (var item in Model.all)
                        {
                            <div class="ibox social-feed-box">
                                <div class="ibox-content">
                                    <div class="one_diary">
                                        <h3><a onclick="parent.createTab('0803','日志明细','@Url.Action("Details", "Diary", new { area = "Personal" })/@item.DIA_ID')">@item.SUBJECT</a></h3>

                                        <div class="diary_type">工作日志 | 日志日期：@item.DIA_TIME</div>
                                        <br />
                                        <div class="content">
                                            <div class="content-ellipsis">
                                                @Html.Raw(item.CONTENT)
                                            </div>
                                        </div>
                                        <br />
                                        <div class="diary_foot">
                                            <div class="row">
                                                <div class="col-md-6">
                                                </div>
                                                <div class="col-md-6">
                                                    <div class="feed-act">
                                                        <a href="javascript:;">浏览(@item.READERS)</a>
                                                        @*<a onclick="parent.createTab('0803','日志明细','@Url.Action("Details","Diary",new { area="Personal"})/@item.DIA_ID')">浏览</a>*@
                                                        <a href="javascript:void(0)" data-cmd="addtop" hidefocus="hidefocus">置顶</a>
                                                        <a onclick="parent.createTab('0803','日志明细','@Url.Action("Details","Diary",new { area="Personal"})/@item.DIA_ID#comment')">评论(@item.diary_comments.Count)</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                </div>

                            </div>
                        }
                    </div>
                </div>
            </div>
        </div>

        <div role="tabpanel" class="tab-pane" id="profile">
            <div class="widget-box container">
                <div style="margin-bottom:10px;"></div>
                <div class="widget-body ">
                    <div class="widget-main padding-8">
                        @foreach (var item in Model.my)
                        {
                            <div id="diary@(item.DIA_ID)" class="ibox social-feed-box">
                                <div class="ibox-content">
                                    <div class="one_diary">
                                        <h3><a onclick="parent.createTab('0803','日志明细','@Url.Action("Details","Diary",new { area="Personal"})/@item.DIA_ID')">@item.SUBJECT</a></h3>

                                        <div class="diary_type">工作日志 | 日志日期：@item.DIA_TIME</div>
                                        <br />
                                        <div class="content">
                                            <div class="content-ellipsis">
                                                @Html.Raw(item.CONTENT)
                                            </div>
                                        </div>
                                        <br />
                                        <div class="diary_foot">
                                            <div class="row">
                                                <div class="col-md-6">
                                                </div>
                                                <div class="col-md-6">
                                                    <div class="feed-act">
                                                        <a href="javascript:;">浏览(@item.READERS)</a>
                                                        @*<a onclick="parent.createTab('0803','日志明细','@Url.Action("Details","Diary",new { area="Personal"})/@item.DIA_ID')">浏览</a>*@
                                                        <a href="javascript:void(0)" data-cmd="addtop" hidefocus="hidefocus">置顶</a>
                                                        <a href="javascript:void(0)" data-cmd="del" hidefocus="hidefocus" onclick="delDiary(@item.DIA_ID);">删除</a>
                                                        <a href="javascript:void(0)" onclick="parent.createTab('0801','新建日志','@Url.Action("Edit","Diary",new { area = "Personal" })/@item.DIA_ID')">编辑</a>
                                                        @*<a href="javascript:void(0)" data-cmd="share" hidefocus="hidefocus" onclick="shareDiary(@item.DIA_ID,@(item.TO_ALL?0:1));">@(item.TO_ALL ? "取消共享" : "共享")</a>*@
                                                        <a id="nshare_@(item.DIA_ID)" href="javascript:void(0)" style="display:@(!item.TO_ALL?"none":"inline");" data-cmd="share" hidefocus="hidefocus" onclick="shareDiary(this,@item.DIA_ID,0);">取消共享</a>
                                                        <a id="share_@(item.DIA_ID)" href="javascript:void(0)" style="display:@(item.TO_ALL?"none":"inline");" data-cmd="share" hidefocus="hidefocus" onclick="shareDiary(this,@item.DIA_ID,1);">共享</a>
                                                        <a onclick="parent.createTab('0803','日志明细','@Url.Action("Details","Diary",new { area="Personal"})/@item.DIA_ID#comment')">评论(@item.diary_comments.Count)</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        }
                    </div>
                </div>
            </div>
        </div>

        <div role="tabpanel" class="tab-pane" id="messages">
            <div class="widget-box container">
                <div style="margin-bottom:10px;">

                </div>
                <div class="widget-body ">
                    <div class="widget-main padding-8">
                        @foreach (var item in Model.other)
                        {
                            <div class="ibox social-feed-box">
                                <div class="ibox-content">
                                    <div class="one_diary">
                                        <h3><a onclick="parent.createTab('0803','日志明细','@Url.Action("Details", "Diary", new { area = "Personal" })/@item.DIA_ID')">@item.SUBJECT</a></h3>

                                        <div class="diary_type">工作日志 | 日志日期：@item.DIA_TIME</div>
                                        <br />
                                        <div class="content">
                                            <div class="content-ellipsis">
                                                @Html.Raw(item.CONTENT)
                                            </div>
                                        </div>
                                        <br />
                                        <div class="diary_foot">
                                            <div class="row">
                                                <div class="col-md-6">
                                                </div>
                                                <div class="col-md-6">
                                                    <div class="feed-act">
                                                        <a href="javascript:;">浏览(@item.READERS)</a>
                                                        @*<a onclick="parent.createTab('0803','日志明细','@Url.Action("Details","Diary",new { area="Personal"})/@item.DIA_ID')">浏览</a>*@
                                                        <a href="javascript:void(0)" data-cmd="addtop" hidefocus="hidefocus">置顶</a>
                                                        <a onclick="parent.createTab('0803','日志明细','@Url.Action("Details","Diary",new { area="Personal"})/@item.DIA_ID#comment')">评论(@item.diary_comments.Count)</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        }
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script src="@Url.Content("~/Content/js/vue.min.js")"></script>
    <script type="text/javascript">

        var delDiary = function(diaryId) {
            layer.confirm('是否确认删除此日志', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.post("/Personal/Diary/DiaryDelete", { id: diaryId }, function (result) {
                    if (result.code == 100) {
                        $("#diary" + diaryId).remove();
                        layer.msg('删除日志成功！', {
                            icon: 1,
                            time: 2000//2s后自动关闭
                        });
                        return false;
                    }
                    alert("删除失败！");
                });
            }, function () {

            });
        }

        var shareDiary = function (node, diaryId, isShared) {
            var content = !isShared ? "取消共享" : "共享";
            layer.confirm("是否确认" + content + "此日志", {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.post("/Personal/Diary/DiaryShare", { id: diaryId, isShared: isShared }, function (result) {
                    if (result.code == 100) {
                        $(node).hide();
                        $((isShared == 0 ? "#share_" : "#nshare_") + diaryId).show();
                        layer.msg(content+"日志成功！", {
                            icon: 1,
                            time: 2000//2s后自动关闭
                        });
                        return false;
                    }
                    alert(content + "日志失败！");
                });
            }, function () {

            });
        }
    </script>
}
